package yf.mall.controller.api.app;

import com.yf.response.R;
import com.yf.service.QiniuService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import yf.mall.vo.app.QiniuUpTokenVO;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/app/mini/qiniu")
public class ApiAppQiniuController {

    @Value("${Qiniu.url}")
    private String uploadUrl;

    @Resource
    private QiniuService qiniuService;


    /**
     * 七牛上传token
     * @return
     */
    @PostMapping("/token")
    public R qiniu(){
        String token = qiniuService.getToken();
        return R.ok(new QiniuUpTokenVO(token,3600L,uploadUrl));
    }


}
